package top.withu.gaof.freehope.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import top.withu.gaof.freehope.model.ArticleModel;

@Repository
public interface ArticleDao extends JpaRepository<ArticleModel, String>{
	
	@Query(value= "select * from t_ipf_article where is_Enabled = ?1 GROUP BY article_Type", nativeQuery= true)
	List<ArticleModel> findByIsEnabled(Boolean isEnabled);
	
	@Query(value= "select distinct(article_Type) from t_ipf_article where is_Enabled = ?1", nativeQuery= true)
	List<String> findArticleType(Boolean isEnabled);
	
	List<ArticleModel> findByArticleTypeAndIsEnabled(String article, Boolean isEnabled);
	
	ArticleModel findOneById(int id);

}
